var Page = {};
Page.init = function()
{
  Ext.QuickTips.init();
  Ext.form.Field.prototype.msgTarget = "side";
  //Ext.get("login-form-box").boxWrap();
  var loginForm = new Ext.form.Form(
  {
    method: "post",
    labelWidth: 140,
    url: "/sucri",
    baseParams: {action: "login"},
    //labelSeperator:"",
    labelAlign: "right",
    buttonAlign: "left",
    waitMsgTarget : true
  }
      );
  loginForm.on("actioncomplete", function(t, a)
  {
    window.location.replace("/sucri?action=userinfo");
  });
  loginForm.on("actionfailed", function()
  {
    Ext.MessageBox.alert("Login Failure!", "Incorrect username or password. You may try again, but be aware that all login attempts are logged and monitored.");
  });
  loginForm.add(
      new Ext.form.TextField(
      {
        name: "username",
        fieldLabel: "Username",
        width: 140,
        allowBlank: false
      }
  ),
      new Ext.form.TextField(
      {
        name: "password",
        fieldLabel: "Password",
        inputType: "password",
        width: 140,
        allowBlank: false
      }
  ));
  loginForm.addButton("Log in", function() { loginForm.submit(); });
  loginForm.addButton("Reset", function()  { loginForm.reset();  });
  loginForm.render("login-form");
};

Ext.onReady(Page.init, Page, true);
